<template>
  <div>
    <h3>
      董洪坤的黑店
      <Mypord
        v-for="item in list"
        :key="item.id"
        :id="item.id"
        :price="item.proprice"
        :desc="item.desc"
        :uname="item.proname"
        @sayPrice="fatherSayPrice"
      ></Mypord>
    </h3>
  </div>
</template>

<script>
import Mypord from './MyProd.vue'
export default {
  components: {
    Mypord,
  },
  data() {
    return {
      list: [
        {
          id: 1,
          proname: '超级好吃棒棒糖',
          proprice: 188,
          low: 160,
          desc: '甜',
        },
        {
          id: 2,
          proname: '超级好吃的大鸡腿',
          proprice: 360,
          low: 320,
          desc: '香',
        },
        { id: 3, proname: '超级无敌冰激凌', proprice: 42, low: 30, desc: '冰' },
      ],
    }
  },
  methods: {
    fatherSayPrice(id) {
      // console.log('我是父组件里的事件')
      this.list.forEach((item) => {
        if (item.id === id) {
          item.proprice > item.low
            ? (item.proprice -= 10)
            : alert('破产了，哥哥别砍了')
        }
      })
    },
  },
}
</script>

<style></style>
